//
//  STHairHouseListView.m
//  YiYueHairdresser
//
//  Created by zhouzhouzhou on 2018/10/9.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STHairHouseListView.h"


@implementation STHairHouseListView


-(void)setHairHouseListView:(int)sign data:(id)data{
    isSign =sign;
    arrHouse = data;
    [self loadHouseView];
}

-(void)loadHouseView{
    if (!houseListView) {
        houseListView = [[UITableView alloc]initWithFrame:self.bounds style:UITableViewStylePlain];
        houseListView.delegate = self;
        houseListView.dataSource = self;
        houseListView.separatorStyle = UITableViewCellSelectionStyleNone;
        houseListView.backgroundColor = [UIColor clearColor];
        houseListView.tableFooterView = [UIView new];
        houseListView.sectionHeaderHeight = 10;
        [self addSubview:houseListView];
    }else{
        [houseListView reloadData];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return arrHouse.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  280;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString * identifier = @"orderCell";
    STHairHouseCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[STHairHouseCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
    }
    STHairHouseListModel *houseDic =arrHouse[indexPath.row];
    cell.type = isSign;
    [cell setHouseInfoWithData:houseDic];
    
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([self.delegate respondsToSelector:@selector(hairHouseListSelNum:)]) {
        [self.delegate hairHouseListSelNum:indexPath.row];
    }
}
@end
